package com.day01;

public class StringTest {

    public static void main(String[] args) {
        //练习1
        char c = 'a'; //97  A:65

        int num = 10;

        String str = "hello";
        //任何数据和String做相加运算都会变成String

        System.out.println(c + num + str);//107hello
        System.out.println(c + str + num);//ahello10
        System.out.println(c + (num + str));//a10hello
        System.out.println((c + num) + str);//107hello
        System.out.println(str + num + c);//hello10a

        //练习2
        //输出* *
        System.out.println("*   *");//OK
        System.out.println('*' + '\t' + '*'); //93
        System.out.println('*' + "\t" + '*'); //OK
        System.out.println('*' + '\t' + "*"); //51*
        System.out.println('*' + ('\t' + "*"));//OK

        //强化练习
//        String str1 = 4;//no
        String str2 = 3.5f + "";//yes
        System.out.println(str2); //"3.5"
        System.out.println(3 + 4 + "Hello!"); //输出7Hello!
        System.out.println("Hello!" + 3 + 4); //输出Hello!34
        System.out.println('a' + 1 + "Hello!"); //输出98Hello!
        System.out.println('a' + 1 + "Hello!");//输出98Hello!
        System.out.println("Hello" + 'a' + 1); //输出Helloa1

        //强化练习
        short s = 5;
//        s = s - 2;//no
        byte b = 3;
//        b = b + 4；//no
        b = (byte) (b + 4); //yes

        char cc = 'a';
        int i = 5;
        float d = .314F;
        double result = c + i + d; // 可以因为double的范围最大，可以像上兼容

        //**************
//        String str1 = 123;
        String str1 = 123 + "";
//        int str11 = (int) str1;
    }

}
